broadway: Send actual float32, not some hack
authorAlexander Larsson <alexl@redhat.com>
Fri, 22 Mar 2019 12:42:26 +0000 (13:42 +0100)
committerAlexander Larsson <alexl@redhat.com>
Tue, 26 Mar 2019 16:07:47 +0000 (17:07 +0100)
gdk/broadway/broadway.js
gsk/gskbroadwayrenderer.c

index fc55f4b59bb1ca2a9c76bde30b8f3dd39ec9d6d0..86259aa0a5d3b01c63740875aa71b863b8882190 100644 (file)
@@ -316,6 +316,12 @@ SwapNodes.prototype.decode_int32 = function() {
     return v;
 }
 
+SwapNodes.prototype.decode_float = function() {
+    var v = this.node_data.getFloat32(this.data_pos, true);
+    this.data_pos += 4;
+    return v;
+}
+
 SwapNodes.prototype.decode_color = function() {
     var rgba = this.decode_uint32();
     var a = (rgba >> 24) & 0xff;
@@ -330,10 +336,6 @@ SwapNodes.prototype.decode_color = function() {
     return c;
 }
 
-SwapNodes.prototype.decode_float = function() {
-    return this.decode_int32() / 256.0;
-}
-
 SwapNodes.prototype.decode_size = function() {
     var s = new Object();
     s.width = this.decode_float ();
index 552c9beafb14ec15e1e866d82794e3678af5f467..9350a2ab1f523a09c293941b8f34eaae6a30c249 100644 (file)
@@ -72,12 +72,25 @@ gsk_broadway_renderer_render_texture (GskRenderer           *renderer,
   return texture;
 }
 
+/* uint32 is sent in native endianness, and then converted to little endian in broadwayd when sending to browser */
 static void
 add_uint32 (GArray *nodes, guint32 v)
 {
   g_array_append_val (nodes, v);
 }
 
+static void
+add_float (GArray *nodes, float f)
+{
+  union {
+    float f;
+    guint32 i;
+  } u;
+
+  u.f = f;
+  g_array_append_val (nodes, u.i);
+}
+
 static guint32
 rgba_to_uint32 (const GdkRGBA *rgba)
 {
@@ -96,14 +109,6 @@ add_rgba (GArray *nodes, const GdkRGBA *rgba)
   g_array_append_val (nodes, c);
 }
 
-static void
-add_float (GArray *nodes, float f)
-{
-  gint32 i = (gint32) (f * 256.0f);
-  guint u = (guint32) i;
-  g_array_append_val (nodes, u);
-}
-
 static void
 add_xy (GArray *nodes, float x, float y, float offset_x, float offset_y)
 {